#pragma once
#include <SFML\Graphics.hpp>
#include <list>
#include <memory>

#define MAX_SHADOWCASTER_LIGHTSCOUNT 32

class LightSource :
	sf::Transformable
{
private : 
	friend class ShadowCaster;
	float _spreadAngle = 0;
	float _radius = 0;
public:
	LightSource(){}
	LightSource(float spreadAngle = 2.f*3.1415f, float radius = 0.f)
		: _spreadAngle(spreadAngle), _radius(radius)
	{ }

	void setSpreadAngle(float spreadAngle) { _spreadAngle = spreadAngle; }
	void setRadius(float radius) { _radius = radius; }
};

class ShadowCaster :
	public sf::Drawable
{
private:
	std::list<LightSource*> _lightSources;

public:
	ShadowCaster()
	{
	}

	~ShadowCaster()
	{
	}

	void bind(LightSource& const lightSource)
	{
		_lightSources.push_back(&lightSource);
	}

	void unbind(LightSource& const lightSource)
	{
		_lightSources.remove(&lightSource);
	}

	void unbindAll()
	{
		_lightSources.clear();
	}

protected:
	virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const override
	{
		/*sf::RectangleShape shape(sf::Vector2f(100, 100));
		shape.setFillColor(sf::Color::Magenta);
		target.draw(shape, sf::RenderStates(sf::BlendMultiply));*/
	}
};

